package com.example.demo.controller;// UserController.java

import com.example.demo.pojo.User;
import com.example.demo.pojo.UserDTO;
import com.example.demo.pojo.UserIdDTO;
import com.example.demo.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description
 * @author LLZ
 * @date 2024/4/7
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/getUserById")
    public User getUserById(@RequestParam("id") String id) {
        return userService.getUserById(id);
    }

    @GetMapping("/getUserByUsername")
    public User getUserByUsername(@RequestParam("username") String username) {
        return userService.getUserByUsername(username);
    }

    @PostMapping("/createUser")
    public int createUser(@RequestBody UserDTO dto) {
        return userService.createUser(dto);
    }

    @PostMapping("/updateUser")
    public int updateUser(@RequestBody UserDTO dto) {
        return userService.updateUser(dto);
    }

    @PostMapping("/deleteUserById")
    public int deleteUser(@RequestBody UserIdDTO dto) {
        return userService.deleteUser(dto);
    }

//    @GetMapping("/test")
//    public String test() {
//        return "Hello world!";
//    }

    @GetMapping("test")
    public String test() {
        return "com/example/demo/file/test";
    }

//    /**
//     * 流程节点上传配置文件
//     *
//     * @return
//     */
//    @PostMapping("vertex/config/upload")
//    public CommonResult<String> configUpload(@RequestParam(value = "processId") Long processId,
//                                             @RequestParam(value = "versionId") Long versionId,
//                                             @RequestParam(value = "nodeId") String nodeId,
//                                             @RequestParam(value = "fileUrl") String fileUrl,
//                                             @RequestParam(value = "file", required = false) MultipartFile file) {
//        ProcessNodeParamVO paramVO = new ProcessNodeParamVO();
//        paramVO.setProcessId(processId);
//        paramVO.setVersionId(versionId);
//        paramVO.setFileUrl(fileUrl);
//        paramVO.setNodeId(nodeId);
//        return CommonResult.success(toolProcessService.uploadConfig(paramVO, file));
//    }
}
